
var mins
var secs;

function cd() {
 	 var min = parseInt(parseInt(secs)/60);
     var sec = parseInt(secs)%60;
    // console.log(min+'');
    // console.log(sec)
     mins = 1 * m(min+''); // change minutes here         
 	 secs = sec; // change seconds here (always add an additional second to your total)
     
 	redo();
}

function m(obj) {
 	for(var i = 0; i < obj.length; i++) {
  		if(obj.substring(i, i + 1) == ":")
  		break;
 	}
 	return(obj.substring(0, i));
}

function s(obj) {    
 	for(var i = 0; i < obj.length; i++) {
  		if(obj.substring(i, i + 1) == ":")
  		break;
 	}
 	return(obj.substring(i + 1, obj.length));
}

function dis(mins,secs) {
 	var disp;
 	if(mins <= 9) {
  		disp = " 0";
 	} else {
  		disp = " ";
 	}
 	disp += mins + ":";
    
 	if(secs <= 9) {
  		disp += "0" + secs;
 	} else {
  		disp += ''+secs;
 	}
    
 	return(disp);
}

function redo() {
    
 	secs--;
 	if(secs == -1) {
  		secs = 59;
  		mins--;
 	}
    
 	document.getElementById('timer').innerHTML = dis(mins,secs); // setup additional displays here.
 	if((mins == 0) && (secs == 0)) {		
		alert('Your session expired!');
		document.testForm.action = document.getElementById('expire_url').value;
  		document.testForm.submit();  		
 	} else {
 		cd = setTimeout("redo()",1000);
 	}
}

function init(s) {

    secs = s;
  	cd();
}